#ifndef __BRIDGE_PACKET__
#define __BRIDGE_PACKET__

#include "cocos2d.h"
#include "../common/include/basedef.h"

 

class LuaPacket : public cocos2d::Ref
{
public:
	LuaPacket(DWORD len = 8 );
	LuaPacket(const BYTE*, int len);
	virtual ~LuaPacket();
	
	void	    Init(const BYTE*, int nBufLen);

	DWORD	    GetPacketSize() const;
	WORD	    GetCmd() const;
	DWORD   	GetFlags() const;

	void    	MakePacket();
	DWORD	    Size() const;
	BYTE*	    Buffer() const;
	void		Copy(const BYTE* buf, DWORD len);
	void        Append(const BYTE* buf, DWORD len);

 
	BYTE		        LuaReadByte();
	WORD		        LuaReadWord();
	WORD	        	LuaReadLong();
	DWORD	        	LuaReadDword();
	UINT64		        LuaReadUINT64();
	INT64		        LuaReadINT64();
	float		        LuaReadFloat();
	double		        LuaReadDouble();
	int		            LuaReadInt();
	bool		        LuaReadBool();
	std::string		    LuaReadString(UINT16 len);
	std::string         LuaReadWString(UINT16 len);
	
 
	BOOL		        LuaWriteByte(BYTE value);
	BOOL		        LuaWriteWord(WORD value );
	BOOL		        LuaWriteLong(long value);
	BOOL		        LuaWriteDword(DWORD value );
	BOOL		        LuaWriteUINT64(UINT64 value );
	BOOL		        LuaWriteINT64(INT64 value);
	BOOL		        LuaWriteFloat(float value );
	BOOL		        LuaWriteDouble(double value );
	BOOL		        LuaWriteInt(int value);
	BOOL		        LuaWriteBool(bool value);
	BOOL		        LuaWriteString(std::string value, UINT16 len );
	BOOL                LuaWriteWString(std::string value, UINT16 len);
	 

private:


};

#endif /* defined(__BRIDGE_LUANETWORK__) */
